﻿/*
SINACOR - BMF&Bovespa
Arquivo: Calendario.cs
Criado em: 27-nov-2009 11:59:14
Arquiteto Responsável: ramelo.7comm
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.ServiceModel;
using System.Text;
using Sinacor.Infra.UI.Common;
using Sinacor.Infra.UI.Security.Services;
using Sinacor.UI.Bovespa.Alocacao.Communication.Bovespa.Alocacao.CoberturaTermo;
using Sinacor.UI.Bovespa.Alocacao.Communication.Bovespa.Calendario.Calendario;

namespace Sinacor.UI.Bovespa.Alocacao.Communication
{
    /// <summary>
    /// Class Calendario
    /// </summary>
    public class Calendario : BaseCommunication
    {

        #region Construtores
        /// <summary>
        /// Construtor padrão
        /// </summary>
        public Calendario()
            : base(default(SessionInformation))
        {
        }

        /// <summary>
        /// Construtor parametrizado
        /// </summary>
        /// <param name="sessionInformation"></param>
        public Calendario(SessionInformation sessionInformation)
            : base(sessionInformation)
        {
        }
        #endregion Construtores

        #region Métodos

        /// <summary>
        /// ConsultarCalendario
        /// </summary>
        /// <returns></returns>
        public ModelCollection<Model.Calendario> ConsultarCalendario()
        {
            ModelCollection<Model.Calendario> response = null;
            ICalendario servico = null;

            try
            {
                using (ServiceInstance<ICalendario> service = new ServiceInstance<ICalendario>())
                {
                    servico = service.TryGetInstance(this.Session);

                    Translator.DataContractToModel.Calendario toCalendario =
                        new Translator.DataContractToModel.Calendario();

                    response = toCalendario.ToCalendario(servico.ConsultarCalendario());
                }
            }
            catch (Exception ex)
            {
                base.HandleFault(ex);
                return null;
            }

            return response;

        }
        #endregion Métodos

    }
}